home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 1
/
Amiga Tools.iso
/
s
/
insert_adrletter.ced
< prev
next >
Wrap
Text File
|
1994-06-06
|
5KB
|
283 lines
/************************************************************************
*
* insert_adrletter.ced by Dirk Federlein 1993
*
* Inserts an address into an already done letter head.
* You may use the following fill-ins, when creating your
* letter head template:
* - <Date>
* - <Address>
* - <First>
* - <Name>
* - <Street>
* - <ZIP>
* - <City>
* - <Country>
*
* You may write the part of the desired address anywhere to the
* letter head template. It is deleted by the script, before the
* parts of the address are inserted!
*
* Up to now every item may occur up to three times. This limit is
* done because of a bug (?) in CEDs Arexx-Port the
* __global__ replace does not work and a walk around had to be
* found! If YOU find another way of doing multiple replaces, please
* send me the modified script, so I can include it into the
* distribution --- Thanx.
*
* Lookup part taken from:
*
* LookUp.ced Copyright (c) 1989, Peter Cherna
*
* ARexx program for CygnusEd Professional that looks up the word under
* the cursor.
*
* Version 1.30: August 20, 1989 Release 1.2: August 29, 1989
*
************************************************************************/
options results
address 'rexx_ced'
tabchar = '09'X
cr = '0A'X
/* Get contents of current line: */
status 55
line = result
/* Get tab size: */
status 8
tabadjust = result - 1
/* Get cursor x position (relative to beginning of line = 1): */
status 46
cur = result + 1
i = index(line,tabchar)
DO while i > 0 & i <= cur - tabadjust
cur = cur - tabadjust
i = index(line,tabchar,i+1)
END
/* If the current character is non-alphabetic, then start one character
over to the left. This allows the cursor to be immediately after
the key word (say on a space or bracket.) */
char = substr(line,cur,1)
if (~(datatype(char,'A') | char = '_') & cur > 1) then
cur = cur - 1
/* Find leftmost and rightmost alphabetic character adjacent to current: */
right = cur - 1
left = cur + 1
char = 'A'
DO while (datatype(char,'A') | char = '_') & (left > 0)
left = left - 1
if left > 0 then
char = substr(line,left,1)
END
char = 'A'
DO while (datatype(char,'A') | (char = '_'))
right = right + 1
char = substr(line,right,1)
END
if right-left <= 1 then
DO
getstring
target = result
if (target = 'RESULT') then
exit
END
else
DO
target = substr(line,left+1,right-left-1)
newtarget = '#?'target'#?'
END
DO
say 'Searching for address' newtarget '...'
if ~show(ports, DFA) then
do
'okay1' 'You should have DFA running, if you' cr 'want to get an address from it!'
exit 0
end
address 'DFA' "SEARCH" newtarget "IGNORECASE FIELDS=ALL STEM ADR."
if rc=0 then
do
"Prev WORD"
"Mark BLOCK"
"NEXT WORD"
"CUT BLOCK"
"Beg of File"
"Replace" '<Address>' ADR.ADDRESS.0
"Replace" '<Address>' ADR.ADDRESS.0
"Replace" '<Address>' ADR.ADDRESS.0
"Beg of File"
"Replace" '<First>' ADR.ADDRESS.2
"Replace" '<First>' ADR.ADDRESS.2
"Replace" '<First>' ADR.ADDRESS.2
"Beg of File"
Replace '<Name>' ADR.ADDRESS.1
Replace '<Name>' ADR.ADDRESS.1
Replace '<Name>' ADR.ADDRESS.1
"Beg of File"
Replace '<Street>' ADR.ADDRESS.3
Replace '<Street>' ADR.ADDRESS.3
Replace '<Street>' ADR.ADDRESS.3
"Beg of File"
Replace '<ZIP>' ADR.ADDRESS.4
Replace '<ZIP>' ADR.ADDRESS.4
Replace '<ZIP>' ADR.ADDRESS.4
"Beg of File"
Replace '<City>' ADR.ADDRESS.5
Replace '<City>' ADR.ADDRESS.5
Replace '<City>' ADR.ADDRESS.5
"Beg of File"
Replace '<Country>' ADR.ADDRESS.6
Replace '<Country>' ADR.ADDRESS.6
Replace '<Country>' ADR.ADDRESS.6
"Beg of File"
/* Get date */
address command 'c:date > ' 'ram:tmp_date'
Search for '<Date>' 'U'
if RESULT then
do
/* Clear Date */
Delete
Delete
Delete
Delete
Delete
Delete
/* Insert Date from temporary file */
include file "ram:tmp_date"
/* "Insert" inserts to the NEXT line */
/* Now move it back */
Down
'Beg of line'
Backspace
/* Delete all stuff from date string that */
/* is not wanted */
"Mark block"
"Next word"
"Cut block"
"text" ' '
"Next word"
"Next word"
"Next word"
"Next word"
"Next word"
"Delete to EOL"
end
Search for '<Date>' 'U'
if RESULT then
do
LEFT
/* Clear Date */
Delete
Delete
Delete
Delete
Delete
Delete
/* Insert Date from temporary file */
include file "ram:tmp_date"
/* Delete all stuff from date string that */
/* is not wanted */
"Mark block"
"Next word"
"Cut block"
"text" ' '
"Next word"
"Next word"
"Next word"
"Next word"
"Next word"
"Delete to EOL"
end
Search for '<Date>' 'U'
if RESULT then
do
LEFT
/* Clear Date */
Delete
Delete
Delete
Delete
Delete
Delete
/* Insert Date from temporary file */
include file "ram:tmp_date"
/* Delete all stuff from date string that */
/* is not wanted */
"Mark block"
"Next word"
"Cut block"
"text" ' '
"Next word"
"Next word"
"Next word"
"Next word"
"Next word"
"Delete to EOL"
end
/* Delete temporary date file */
address command 'c:delete ' 'ram:tmp_date'
end
else
'okay1' 'Could not find address of' newtarget '! '
END
exit